package com.iqik.rabbit.listen;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

@Component
public class CancelListener implements ChannelAwareMessageListener {

    @RabbitListener(queues = "queue.dlx.order", ackMode = "MANUAL")
    public void onMessage(Message message, Channel channel) throws Exception {
        String orderId = new String(message.getBody());
        System.out.println("订单支付超时 取消订单: " + orderId);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
